package sjtu.rfid.rri.services.ale.cyclecontrol;

import java.util.List;

import sjtu.rfid.rri.services.ale.exception.InvalidURIException;
import sjtu.rfid.rri.services.ale.trigger.Trigger;

public interface CycleContext {
	/**
	 * change the status of the cycle according to the Event. <br>
	 * This method should be implemented as synchronization in subclass!
	 * 
	 * @param event
	 *            the triggered event
	 * @param trigger
	 *            the trigger which triggers this event. Leave null if the event
	 *            is triggered by ALE Services.
	 */
	void change(Event event, Trigger trigger);

	/**
	 * Get the current state of the cycle.
	 * 
	 * @return the current state of the cycle.
	 */
	String getState();

	List<String> getSubscribers();

	void addSubscriber(String notificationURI) throws InvalidURIException;

	void removeSubscriber(String notificationURI) throws InvalidURIException;

	void upPollCount();

	void downPollCount();

	/**
	 * get all in-queue descriptions related with this Cycle!
	 * 
	 * @return
	 */
	List<String> getInQueueDescriptions();

	/**
	 * get all out-queue descriptions related with this Cycle!
	 * 
	 * @return
	 */
	List<String> getOutQueueDescriptions();

	/*
	 * setter/getter
	 */
	boolean isHasRepeatPeriod();

	void setHasRepeatPeriod(boolean hasRepeatPeriod);

	boolean isRepeatPeriodElapsed();

	void setRepeatPeriodElapsed(boolean repeatPeriodElapsed);

	boolean isHasStartTriggers();

	void setHasStartTriggers(boolean hasStartTriggers);

	boolean isHasSubscribers();

	void setHasSubscribers(boolean hasSubscribers);

	boolean isHasPollCalls();

	void setHasPollCalls(boolean hasPollCalls);

}
